{{extend 'layout.html'}}

<div class="breadcrumbs">
    <a class="breadcrumbs" href="{{=URL(r=request, c='default', f='index')}}" title="Home">Home</a>
    /
    {{=view_info['forum'].forum_title}}
    /
    <b>Add New Topic</b>
</div>

{{include 'default/err_check.html'}}

{{if view_info.has_key('preview'):}}
    <div class="preview bottom-separator">
        <b>Message Preview</b>
        <div class="hr"><hr /></div>
        <div>{{=XML(view_info['preview'])}}</div>
    </div>
{{pass}}

<form id="add_topic_form" method="post">
    <fieldset id="add_topic_form_fields">
        <input type="hidden" id="form_submitted" name="form_submitted" value="1" />
        <input type="hidden" id="forum_id" name="forum_id" value="{{=forum_id}}" />
        <input type="hidden" id="c" name="c" value="{{=view_info['anon_captcha_base64']}}" />
        <table cellspacing="2" cellpadding="1">
        <tbody>
            <tr>
                <td>Author:</td>
                <td>
                    {{=forumhelper.get_display_name()}}
                    <a href="javascript:void(0)"
                    style="font-style: italic;"
                    onclick="PyforumJS.Controller.Helper.changeUser();">(How do I change this?)</a></td>
            </tr>
            <tr>
                <td><span class="required">*</span> Title:</td>
                <td><input type="text" id="title" name="title" value="{{=request.vars.get('title', '')}}" style="width:600px;" /></td>
            </tr>
            <tr>
                <td><span class="required">*</span> Content:</td>
                <td><textarea id="content" name="content" cols="0" rows="0" style="width:600px;height:250px;">{{=request.vars.get('content', '')}}</textarea></td>
            </tr>
            {{if not auth.is_logged_in():}}
                <tr>
                    <td><span class="required">*</span>
                        Verify your humanity:
                    </td>
                    <td>
                        <input type="text" id="captcha_response" name="captcha_response" value="" style="width:100px;" />
                        <b>{{=view_info['anon_captcha']}}</b>
                        <span class="warning">(Please Enter the acces code shown in order to post your message.)</span>
                    </td>
                </tr>
            {{pass}}
            {{if auth.is_logged_in():}}
                <tr>
                    <td><label for="add_signature">Add Signature:</label></td>
                    <td><input type="checkbox" id="add_signature" name="add_signature" {{if request.vars.get('add_signature', ''):}}checked="checked"{{pass}} /></td>
                </tr>
                <tr>
                    <td><label for="add_subscription">Subscribe Immediately:</label></td>
                    <td><input type="checkbox" id="add_subscription" name="add_subscription" {{if request.vars.get('add_subscription', ''):}}checked="checked"{{pass}} /></td>
                </tr>
            {{pass}}
            {{if auth.has_membership(forum_memberships['FORUM_ADMINISTRATOR']):}}
                <tr>
                    <td><span class="warning">*</span> <label for="locked_flag">Locked Topic:</label></td>
                    <td><input type="checkbox" id="locked_flag" name="locked_flag" {{if request.vars.get('locked_flag', ''):}}checked="checked"{{pass}} /></td>
                </tr>
                <tr>
                    <td><span class="warning">*</span> <label for="sticky_flag">Sticky Topic:</label></td>
                    <td><input type="checkbox" id="sticky_flag" name="sticky_flag" {{if request.vars.get('sticky_flag', ''):}}checked="checked"{{pass}} /></td>
                </tr>
                <tr>
                    <td><span class="warning">*</span> <label for="system_announcement_flag">System Announcement:</label></td>
                    <td><input type="checkbox" id="system_announcement_flag" name="system_announcement_flag" {{if request.vars.get('system_announcement_flag', ''):}}checked="checked"{{pass}} /></td>
                </tr>
                <tr>
                    <td><span class="warning">*</span> Created:</td>
                    <td>
                        <input type="text" id="creation_date" name="creation_date" value="{{=request.vars.get('creation_date', request.now.strftime('%Y-%m-%d %H:%M:%S'))}}" style="width:200px;" />
                    </td>
                </tr>
                <tr>
                    <td><span class="warning">*</span> Modified:</td>
                    <td>
                        <input type="text" id="modifying_date" name="modifying_date" value="{{=request.vars.get('modifying_date', request.now.strftime('%Y-%m-%d %H:%M:%S'))}}" style="width:200px;" />
                    </td>
                </tr>
            {{pass}}
            <tr>
                <td>Click on an emoticon to add it:</td>
                <td>
                    {{for icon in view_info['emoticons']:}}
                        <img src="{{=URL(r=request, c='static/images', f=icon)}}" alt="{{=icon[5:icon.rfind('.')]}}" class="imgclear" style="width:16px;height:16px;"
                             onmouseover="this.style.cursor='pointer';"
                             onmouseout="this.style.cursor='default';"
                             onclick="add_emoticon('{{=icon[5:icon.rfind('.')]}}');" />
                    {{pass}}
                </td>
            </tr>
        </tbody>
        </table>

        <div class="both-separator"><span class="required">* Required Fields</span></div>

        <input type="submit" id="preview_b" name="preview_b" value="Preview" />
        <input type="submit" id="add_topic" name="add_topic" value="Add" />
        <input type="submit" id="cancel_b" name="cancel_b" value="Cancel" />

    </fieldset>
</form>

<div class="top-separator">
    <span class="warning">* - Adminitrative-only options, not available to regular members.</span>
</div>

<script>
    <!--
        PyforumJS.Controller.initTextareaEditor();
    //-->
</script>
